package com.seecen.HJM.controller;

import com.seecen.HJM.model.dto.ArtistDTO;
import com.seecen.HJM.model.vo.ArtistDetailVO;
import com.seecen.HJM.model.vo.ArtistVo;
import com.seecen.HJM.result.DataVo;
import com.seecen.HJM.result.PageResult;
import com.seecen.HJM.service.ArtistService;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/artist")
public class ArtistController {
    @Autowired
    private ArtistService artistService;
    //获取所有歌手接口
    @PostMapping("/getAllArtists")
    public DataVo<PageResult<ArtistVo>> getAllArtists(@RequestBody @Valid ArtistDTO artistDTO) {

        System.out.println(artistDTO);

        return artistService.getAllArtists(artistDTO);
    }

    //获取随机歌手
    @GetMapping("/getRandomArtists")
    public DataVo<List<ArtistVo>> getRandomArtists() {
        return artistService.getRandomArtists();
    }
    //获取歌手所有信息
    @GetMapping("/getArtistDetail/{id}")
    public DataVo<ArtistDetailVO> getArtistDetail(@PathVariable("id") Long artistId, HttpServletRequest request) {
        return artistService.getArtistDetail(artistId, request);
    }
}
